import { DataListParams, AEParams, DeleteParams } from './model'
import { defHttp } from '/@/utils/http/axios'
import { ErrorMessageMode } from '/@/utils/http/axios/types'

enum Api {
    listData = '/category/list',
    addUrl = '/addCategory',
    deleteUrl = '/category/delete',
}

/**
 * @description: 获取列表
 */
export function dateListApi(params: DataListParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.listData,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}

/**
 * @description: 添加
 */
export function addApi(params: AEParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.addUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}

/**
 * @description: 删除
 */
export function deleteApi(params: DeleteParams, mode: ErrorMessageMode = 'modal') {
    return defHttp.request(
        {
            url: Api.deleteUrl,
            method: 'POST',
            params,
        },
        {
            errorMessageMode: mode,
        }
    )
}
